<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:rich="http://richfaces.org/rich">
	<c:if test="${empty closeButtonLabel}">
		<c:set var="closeButtonLabel" value="Close" />
	</c:if>
	<c:if test="${empty openButtonLabel}">
		<c:set var="openButtonLabel" value="Open" />
	</c:if>
	<c:if test="${empty id}">
		<c:set var="id" value="popupNeedsAnId" />
	</c:if>
	<c:if test="${empty resizeable}">
		<c:set var="resizeable" value="false" />
	</c:if>
	<c:if test="${empty width}">
		<c:set var="width" value="550" />
	</c:if>
	<c:if test="${empty height}">
		<c:set var="height" value="300" />
	</c:if>
	<c:if test="${empty top}">
		<c:set var="top" value="200" />
	</c:if>
	<rich:modalPanel id="${id}Popup" resizeable="${resizeable}"
		width="${width}" height="${height}" top="${top}">
		<h:panelGrid columns="1">
			<ui:insert name="popupBody">
				<h:panelGrid columns="1">
					<h:outputText>
			  Default modalPanel body. To change this, add a ui:define tag with name="popupBody" 
			  inside your cim:popup tag. Add any content inside the ui:define open and close tags.
			  		</h:outputText>
					<h:outputText>
						You can also use the following parameters to change elements of the popup:			  
			  		</h:outputText>
					<h:outputText>
						Parameter: closeButtonLabel - Changes the text on the close-button inside the modalPanel 
			  		</h:outputText>
					<h:outputText>
						Parameter: openButtonLabel - Changes the text on the button that opens the modalPanel
			  		</h:outputText>
					<h:outputText>
						Parameter: id - Sets the id of the modalPanel. This is mandatory for pages where you 
						have more than one popup, because all elements should have a unique id. 
			  		</h:outputText>
					<h:outputText>
						Parameter: resizeable - Set this to true to make the modalPanel resizable like normal windows.
						This is defaulted to false in the cim:popup panel. 
			  		</h:outputText>
					<h:outputText>
						Parameter: width - Sets the width of the modalPanel. Default is 450. 
			  		</h:outputText>
					<h:outputText>
						Parameter: height - Sets the height of the modalPanel. Default is 200. 
			  		</h:outputText>
					<h:outputText>
						Parameter: top - Sets the top position of the modalPanel. Default is 200.
						Horizontal position of the modalPanel is centered.  
			  		</h:outputText>
				</h:panelGrid>
			</ui:insert>
			<ui:insert name="closeButton">
				<h:commandButton value="${closeButtonLabel}"
					onclick="Richfaces.hideModalPanel('${id}Popup')" />
			</ui:insert>
		</h:panelGrid>
	</rich:modalPanel>
	<ui:insert name="openButton">
		<h:commandButton value="${openButtonLabel}"
			onclick="
		Richfaces.showModalPanel('${id}Popup',{width:${width}, heigth: ${height}, top:${top}})" />
	</ui:insert>
</ui:composition>